import os, sys
from pylab import *

eos_dir = 'EoS'

eos_ensemble = []

# load all EoS results
N = 100
for i in range(1,N+1):
    ftmp= os.path.join('.',eos_dir,'eos_'+str(i)+'.txt')
    tmp = loadtxt(ftmp)
#    print('EoS_%d:\n'%(i))
#    print(tmp[:,0])
    eos_ensemble.append(list(tmp[:,0]))

eos_ensemble = array(eos_ensemble)
#print(eos_ensemble)

a = linspace(1.0,0.4,20)
z = 1./a - 1.0
w = mean(eos_ensemble,axis=0)
dw = std(eos_ensemble,axis=0)
#plot(z,w+1,label='ensemble average')
errorbar(z,w,yerr=dw,label='ensemble average')
legend(loc='best')
show()
